package offer;

public class offer_0039 {
    public int majorityElement(int[] nums) {
        int len=nums.length;
        int current=nums[0];
        int time=0;
        for(int i=0;2*i<len;++i){
            if(nums[i]==nums[len-1-i]){
                if(time==0){
                    time+=2;
                    current=nums[i];
                }
                else if(current==nums[i]) time+=2;
                else time-=2;
            }
        }
        return current;
    }
}
